package org.leon.controller;

import org.leon.CustomerAnnotation;
import org.leon.repo.Animal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;

import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@Controller
public class DemoController {


    @CustomerAnnotation
    @Autowired(required = false)
    private List<Animal> entityList = Collections.emptyList();

    @Autowired
    private ApplicationContext applicationContext;


    @PostConstruct
    public void init(){
        Map<String, Animal> beans = applicationContext.getBeansOfType(Animal.class);
        for (var s : beans.entrySet()) {
            s.getValue().speak();
        }
        //entityList.forEach( a -> a.speak());
    }


}
